package com.kongwg.java2;

import org.junit.Test;

/**
 * @author kongwg
 * @create 2020-12-30 18:19
 */
public class ArrayTest {

    @Test
    public void test1() {
        String[] stringArray = new String[3];
        for (int i = 0; i < stringArray.length; i++) {
            System.out.println(stringArray[i]);

        }

    }

    @Test
    public void test2() {
        /**
         * 创建一个长度为6的int型数组，要求取值为1-30，同时元素值各不相同
         */
        int[] arr = new int[6];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 30 + 1);

            for (int j = 0; j < i; j++) {
                if (arr[i] == arr[j]) {
                    i--;
                    break;
                }

            }

        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        float[] d = {1, 2, 2};
    }

    @Test
    public void test3() {  /**
     *用数组求出斐波那契数列的前20项值
     *
     */
    int temp = 100;
        long a = 1;
        long b = 1;
        long c = 0;
        System.out.print(1 + "\t" + 1 +"\t");
        for (int i = 0; i < temp; i++) {
            c = a + b;
            a = b;
            b = c;
            System.out.print(c + "\t");
        }

    }

    @Test
    public void test4(){
        /**
         * 冒泡排序
         */


    }


}

